package cn.imvc.app.models;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.stereotype.Service;

import cn.imvc.app.entities.Area;
import cn.imvc.app.repositories.AreaRepository;
import cn.imvc.core.ModelUtil;
import cn.imvc.data.domain.ViewRequest;

@Service
public class AreaModelImpl implements AreaModel {
	@Autowired
	private AreaRepository areaRepository;

	public List<Area> findAllProvinces() {
		return areaRepository.findAllByDeep((byte) 1);
	}

	public List<Area> findAllCitys(int areaId) {
		return areaRepository.findAllByParent(areaRepository.getOne(areaId));
	}

	public List<Area> findAllCountrys(int areaId) {
		return areaRepository.findAllByParent(areaRepository.getOne(areaId));
	}

	public Area get(int id) {
		return areaRepository.findOne(id);
	}

}
